package com.hopes.bizz.basic.common.service;

import com.hopes.bizz.basic.hazard.sds.mapper.HazChemicalSdsMapper;
import com.hopes.bizz.basic.hazard.sds.mapper.HazPictogramMapper;
import com.hopes.bizz.basic.hazard.source.mapper.HazHazardSourceMapper;
import com.hopes.bizz.basic.hazard.source.mapper.HazMonitorFactorMapper;
import com.hopes.bizz.basic.hazard.source.mapper.HazStorageMapper;
import com.hopes.bizz.basic.park.mapper.BaseShiftEmployeeMapper;
import com.hopes.bizz.basic.park.mapper.BaseShiftWorkMapper;
import com.hopes.bizz.basic.third.mapper.BaseThirdEmployeeMapper;
import com.hopes.bizz.basic.third.mapper.BaseThirdUnitMapper;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.common.service.TableDictService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yumr
 * @ProjectName bizz
 * @Description 数据表转字典
 * @time 2023/10/18 13:30
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class ParkBasicDictServiceImpl implements TableDictService {

    private final HazHazardSourceMapper hazHazardSourceMapper;
    /**
     * 危险源监控因子
     */
    private final HazMonitorFactorMapper hazMonitorFactorMapper;
    private final HazStorageMapper hazStorageMapper;
    private final HazChemicalSdsMapper hazChemicalSdsMapper;
    private final HazPictogramMapper hazPictogramMapper;
    private final BaseThirdEmployeeMapper baseThirdEmployeeMapper;
    private final BaseThirdUnitMapper baseThirdUnitMapper;
    private final BaseShiftWorkMapper baseShiftWorkMapper;
    private final BaseShiftEmployeeMapper baseShiftEmployeeMapper;

    /**
     * 危险源-监控因子
     *
     * @return 字典数据
     */
    public List<SysDictItem> listMonitorFactorAsDict() {
        return hazMonitorFactorMapper.labelValueList();
    }

    public List<SysDictItem> listHazardSourceAsDict() {
        return hazHazardSourceMapper.labelValueList();
    }

    public List<SysDictItem> listChemicalSdsAsDict() {
        return hazChemicalSdsMapper.labelValueList();
    }

    public List<SysDictItem> listPictogramCodeAsDict() {
        return hazPictogramMapper.labelValueList();
    }

    public List<SysDictItem> listStorageInfoAsDict() {
        return hazStorageMapper.labelValueList();
    }

    public List<SysDictItem> listThirdUnitAsDict() {
        return baseThirdUnitMapper.labelValueList();
    }

    public List<SysDictItem> listThirdEmployeeAsDict() {
        return baseThirdEmployeeMapper.labelValueList();
    }

    public List<SysDictItem> listWorkInfoAsDict() {
        return baseShiftWorkMapper.labelValueList();
    }

    public List<SysDictItem> listShiftEmployeeAsDict() {
        List<SysDictItem> sysDictItems = baseShiftEmployeeMapper.labelValueList();
        sysDictItems
                .forEach(item -> item.setName(DictResolver.getItemLabelByValue(AdminDictEnum.sys_user, item.getName())));
        return sysDictItems;
    }

}
